<template>
  <a-modal
    :title="title"
    :visible="visible"
    :confirm-loading="confirmLoading"
    cancel-text="关闭"
    @ok="submit"
    @cancel="closeModal"
  >
    <a-spin :spinning="confirmLoading">
      <p class="title_text" v-show="action == 0">你确定要显示评价？</p> 
      <p class="title_text" v-show="action == 1">你确定要隐藏评价？</p> 
    </a-spin>
  </a-modal>
</template>

<script>
import ApiTree from '@/api/common/evaluateList';
import { Slime } from '@/mixins/slime';
export default {
  name: 'upDownModal',
  data() {
    return {
      title: '修改隐藏状态',
      id: null,
      action:0, // 0显示 1隐藏
    };
  },
  mixins: [Slime],
  methods: {
    // 详情
    open(id, val) {
      console.log(val)
      this.visible = true;
      this.action = val
      this.id = id
      if(val == 0){
        this.upDownVal = "下架"
      }else{
        this.upDownVal = "上架"
      }
    },
    // 提交
    submit() {
      this.confirmLoading = true;
      const param = {
        id: this.id,
        hide: this.action,
      };
      this.submitUpdate(param);
    },
    // 提交 改
    submitUpdate(param) {
      const that = this;
      this.confirmLoading = false;
      this.visible = false;
      ApiTree.getUpdate(param)
      .then((res) => {
        if(res.code == 0){
          that.$message.success('操作成功');
        }else{
          that.$message.warning(res.message);
        }
      }).finally(() => {
        that.closeModal();
      });
    },
    // 弹窗-关闭
    closeModal() {
      this.confirmLoading = false;
      this.visible = false;
      this.$emit('closeModal');
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.title_text{
  font-size: 14px;
  font-weight: 800;
  color: #000;
}
</style>